import type { AdColumn } from '@/components/AdVxeTable';

import { getMobilePlatformEnumSchema } from '@/enums/mobile/mobilePlatformEnum';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();
const mobilePlatformEnumSchema = getMobilePlatformEnumSchema();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    field: 'Id',
    width: 180,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('mobile.route.app.codeText'),
    field: 'Code',
    width: 180,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('mobile.route.app.platformText'),
    field: 'Platform',
    width: 120,
    formVisible: true,
    required: true,
    filterable: true,
    dataType: 'enum',
    enumData: mobilePlatformEnumSchema,
  },
  {
    title: t('mobile.route.app.nameText'),
    field: 'Name',
    width: 250,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('mobile.route.app.descriptionText'),
    field: 'Description',
    width: 300,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('mobile.route.app.iconText'),
    field: 'Icon',
    width: 70,
    visible: false,
    filterable: false,
    dataType: 'string',
    slots: { default: 'iconCol' },
  },
  {
    title: t('mobile.route.authorText'),
    field: 'Author',
    width: 120,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('mobile.route.emailText'),
    field: 'Email',
    width: 180,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('mobile.route.phoneNumberText'),
    field: 'PhoneNumber',
    width: 160,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('mobile.route.app.appStoreLinkText'),
    field: 'AppStoreLink',
    width: 120,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('mobile.route.app.urlText'),
    field: 'Url',
    width: 120,
    formVisible: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('entity.lockable.isLockedTitle'),
    field: 'IsLocked',
    width: 70,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('entity.creationAudited.creatorIdTitle'),
    field: 'CreatorId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('entity.creationAudited.creatorNameTitle'),
    field: 'CreatorName',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'CreatorId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.creatorNicknameTitle'),
    field: 'CreatorNickname',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'CreatorId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    field: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('entity.updateAudited.updaterIdTitle'),
    field: 'UpdaterId',
    width: 0,
    visible: false,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('entity.updateAudited.updaterNameTitle'),
    field: 'UpdaterName',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UpdaterId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'UserName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updaterNicknameTitle'),
    field: 'UpdaterNickname',
    width: 100,
    formVisible: true,
    formEditable: false,
    filterable: true,
    filterIndex: 'UpdaterId',
    filterJoin: {
      entityType: 'EaCloud.Pack.Identity.Entities.User,EaCloud.Pack.Identity',
      filterField: 'NickName',
      selectField: 'Id',
    },
    dataType: 'string',
  },
  {
    title: t('entity.updateAudited.updatedTimeTitle'),
    field: 'UpdatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
];
